package cn.itcast.solrcloud;

import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.common.SolrInputDocument;
import org.junit.Test;

import java.io.IOException;

public class SolrCloudCreateTest {

    @Test
    public void testCreateIndex() throws IOException, SolrServerException {

        //创建SolrServer
        CloudSolrServer solrServer=new CloudSolrServer("192.168.206.101:2181,192.168.206.102:2181,192.168.206.103:2181");
        //指定要访问的核心
        solrServer.setDefaultCollection("myCollection1");

        SolrInputDocument document=new SolrInputDocument();
        document.addField("id","1212");
        document.addField("title","加油！");

        //添加Document到solrServer
        solrServer.add(document);
        solrServer.commit();

    }
}
